package com.ciwong.epaper.modules.reciteWords.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.reciteWords.bean.LearnedWordBean;
import com.ciwong.epaper.modules.reciteWords.bean.LearnedWordDayListBean;

import java.util.ArrayList;

public class FrgLearnedAdapter extends BaseLearnAdapter<LearnedWordDayListBean> {

    public FrgLearnedAdapter(Context context) {
        super(context);

    }

    @Override
    protected BaseLearnViewHolder creatViewHolder(LayoutInflater from, ViewGroup parent, int viewType) {
        View inflate = from.inflate(R.layout.item_word_learned_out, parent, false);
        return new UnlearnViewHolder(inflate);
    }

    @Override
    protected void binderViewHolder(BaseLearnViewHolder holder, ArrayList<LearnedWordDayListBean> mList, int position) {
        final UnlearnViewHolder mHolder = (UnlearnViewHolder) holder;
        final LearnedWordDayListBean listBean = mList.get(position);
        mHolder.tv_date.setText(listBean.getSubmitDate());
        FrgLearnedInnerAdapter frgLearnedInnerAdapter = new FrgLearnedInnerAdapter(mContext);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        mHolder.rv_fragment_learned.setLayoutManager(linearLayoutManager);
        mHolder.rv_fragment_learned.setAdapter(frgLearnedInnerAdapter);
        frgLearnedInnerAdapter.setData(listBean.getArrayList());
    }


    private class UnlearnViewHolder extends BaseLearnViewHolder {

        public RecyclerView rv_fragment_learned;
        public TextView tv_date;

        public UnlearnViewHolder(View itemView) {
            super(itemView);
        }

        protected void initView(View itemView) {
            rv_fragment_learned = itemView.findViewById(R.id.rv_fragment_learned_item);
            tv_date = itemView.findViewById(R.id.tv_date);

        }
    }
}
